package com.ruoyi.schedule.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.schedule.domain.Rule;
import com.ruoyi.schedule.mapper.RuleMapper;
import com.ruoyi.schedule.service.IRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 排班规则 业务层处理
 */
@Service
public class RuleServiceImpl implements IRuleService {
    @Autowired
    private RuleMapper ruleMapper;

    /**
     * 查询排班规则列表
     */
    @Override
    public List<Rule> selectRuleList(Rule rule) {
        return ruleMapper.selectRuleList(rule);
    }

    /**
     * 新增排班规则
     */
    @Override
    public int insertRule(Rule rule) {
        rule.setCreateBy(SecurityUtils.getUsername());
        return ruleMapper.insertRule(rule);
    }

    /**
     * 修改排班规则
     */
    @Override
    public int updateRule(Rule rule) {
        rule.setUpdateBy(SecurityUtils.getUsername());
        return ruleMapper.updateRule(rule);
    }

    /**
     * 批量删除排班规则
     */
    @Override
    public int deleteRuleByIds(Long[] ruleIds) {
        return ruleMapper.deleteRuleByIds(ruleIds);
    }
}